import asyncio


async def func():
    print(1)
    await asyncio.sleep(2)
    print(2)
    return "返回值"


async def main():
    # 创建协程对象列表
    task_list = [func(), func()]

    loop = asyncio.get_running_loop()
    print(loop)

    tasks = asyncio.all_tasks()
    print(tasks)

    # 使用 asyncio.gather 并发运行协程
    results = await asyncio.gather(*task_list)

    tasks = asyncio.all_tasks()
    print(tasks)
    # 打印每个协程的返回结果
    for result in results:
        print(result)


if __name__ == "__main__":
    asyncio.run(main())
